<% content_for :css do %>
  <%= stylesheet_link_tag 'tasks','customers_show' %>
<% end %>
<% content_for :title do %>联系人-<%= @customer.full_name %><% end %>
<div class="grid_18 customer">
  <% if not @customer.visible_scope.everyone? %>
  <div id="who_can_see" class="grid_18 alpha omega">
    <div class="private">
      <%= image_tag 'customers/private.jpg' %>
    </div>
    <div class="tip <%= @customer.visible_scope %>">      
      仅有<%= @customer.who_can_see.each_with_object([]) {|user,nick_names| nick_names << user.nick_name }.join('，') %>能够看到该联系人资料 <%= link_to '不合适?重新设置...', edit_customer_url(@customer), :id => "tip", :class => :set, :title => '重新设置可见该单的合适人选' %>
    </div>
  </div>  
  <% end %>
  <div class="grid_18 head alpha omega <%= @customer.visible_scope.everyone? ? 'round_top' : '' %>">
    <div class="logo grid_2">
      <div class="logo_border">
        <%= image_tag "users/#{@customer.sex}.png", :width => '64' %>
      </div>
    </div>
    <div class="grid_6 info">
      <div class="name"><%= @customer.full_name %></div>
      <div class="title"><%= @customer.organization %><%= @customer.title %></div>
      <div class="tags">
        <% @customer.tags.each do |tag| %>
          <%= link_to tag.name, customers_url(:tag_id => tag.id), :title => "浏览所有带【#{tag.name}】标签的联系人", :target => :_blank %>
        <% end %>
      </div>
    </div>
    <div class="grid_9 contacts">
      <div class="phone">
        <% if @customer.phones.any? %>
        <%= @customer.phones.first.way %><small><%= @customer.phones.first.type_name %></small>
        <% end %>
      </div>
      <div class="email">
        <% if @customer.emails.any? %>
        <%= link_to_function @customer.emails.first.way,@customer.emails.first.way %>
        <small><%= @customer.emails.first.type_name %></small>        
        <% end %>
      </div>
      <div class="im">
        <% if @customer.ims.any? %>
        <%= @customer.ims.first.way %><small><%= @customer.ims.first.type_name %></small>
        <% end %>
      </div>
    </div>
  </div>
  <div class="grid_12 alpha omega left">
    <div class="add_note block">
      <div class="title grid_11">与<%= @customer.full_name %>的往来记录</div>
      <div class='form_body'>
        <%= render :partial => 'new_record.html', :locals => { :record => ContactRecord.new(:customer_id => @customer.id) } %>      
      </div>      
    </div>
    <div class="clear"></div>
    <div class="notes block">
      <!--div class='tabs'>
        <div class='relative'>
        <% 3.times do |t| %>
          <%= link_to "script", :class => "tab #{t == 0 ? 'h' : ''}"  do  %>
            世纪华庭(<b>12</b>)
          <% end %>
        <% end %>
          <%= link_to_function "+","$('#new_tabs').show('fast')", :class => 'tab add_project', :title => '推荐项目'   %>
        </div>
      </div
      <div id='new_tabs' class='hidden'> 
        <form>
        <div class='line'>
        <div class='dt'>推荐项目</div>     
          <div class='dd'>
          <% 3.times do %>
            <div class='project'>
              <%= link_to "金碧文华", '' , :class => :to_project %>
              <%= link_to_function "移除","", :class => 'l_crud l_close', :title => '点击取消推荐'  %>
            </div>
            <div class="clear"></div>
          <% end %>
            <div class='project'>
              <select>
                <option>请选择</option>
              </select>
            </div>
          </div>
        </div>
        <div class="clear"></div>
        <div class='tools'>
          <%= submit_tag '推荐到这些项目' %>或 <%= link_to_function "离开","$('#new_tabs').hide('fast')", :title => '推出推荐项目操作'  %>
        </div>
        </form>
      </div>-->
      <div class='records'>
        <% @customer.contact_records.each do |record| %>
        <%= render(:partial => 'record_in_show.html', :locals => { :record => record }) %>
        <% end %>
      </div>
    </div>
  </div>
  <div class="grid_6 alpha omega right">
    <!-- <div id='my_tasks' class="block">
      <div class="head">
        <div class="title">我的任务</div>
      </div>
      <div class="body">
      <%# if Task.overdue.waiting.mine.any? %>
        <div class="line overdue">
          <div class="title">逾期</div>
          <%#= render :partial => 'customers/tasks/detail_in_index.html', :locals => {:tasks => Task.overdue.waiting.mine} %>
          <div class='clear'></div>
        </div>
      <%# end %>
      <%# if Task.today.waiting.mine.any? %>
        <div class="line today">
          <div class="title">今天</div>
          <%#= render :partial => 'customers/tasks/detail_in_index.html', :locals => {:tasks => Task.today.waiting.mine} %>
          <div class='clear'></div>
        </div>
      <%# end %>
      <%# if Task.tomorrow.waiting.mine.any? %>
        <div class="line">
          <div class="title">明天</div>
          <%#= render :partial => 'customers/tasks/detail_in_index.html', :locals => {:tasks => Task.tomorrow.waiting.mine} %>
          <div class='clear'></div>
        </div>
      <%# end %>
      <%# if Task.this_week.waiting.mine.any? %>
        <div class="line">
          <div class="title">本周</div>
          <%#= render :partial => 'customers/tasks/detail_in_index.html', :locals => {:tasks => Task.this_week.waiting.mine} %>
          <div class='clear'></div>
        </div>
      <%# end %>
      <%# if Task.next_week.waiting.mine.any? %>
        <div class="line">
          <div class="title">下周</div>
          <%#= render :partial => 'customers/tasks/detail_in_index.html', :locals => {:tasks => Task.next_week.waiting.mine} %>
          <div class='clear'></div>
        </div>
      <%# end %>
      <%# if Task.this_month.waiting.mine.any? %>
        <div class="line">
          <div class="title">本月</div>
          <%#= render :partial => 'customers/tasks/detail_in_index.html', :locals => {:tasks => Task.this_month.waiting.mine} %>
          <div class='clear'></div>
        </div>
      <%# end %>
      <%# if Task.later.waiting.mine.any? %>
        <div class="line">
          <div class="title">随后</div>
          <%#= render :partial => 'customers/tasks/detail_in_index.html', :locals => {:tasks => Task.later.waiting.mine} %>
          <div class='clear'></div>
        </div>
      <%# end %>
      </div>
    </div> -->
    <div class="block">
      <div class="head">
        <div class="title with_tools">联系电话</div>
        <div class="tools">
          <%= link_to @customer.phones.many? ? '编辑' : '添加', edit_customer_url(@customer) %>
        </div>
        <div class="clear"></div>
      </div>
      <div class="body">
        <% @customer.phones.each do |contact|  %>
        <div class="line">
          <%= contact.way %><small><%= contact.type_name %></small>
        </div>
        <% end %>
      </div>      
    </div>
    <div class="block">
      <div class="head">
        <div class="title with_tools">电子邮件</div>
        <div class="tools">
          <%= link_to @customer.emails.many? ? '编辑' : '添加', edit_customer_url(@customer) %>
        </div>
        <div class="clear"></div>
      </div>
      <div class="body">
        <% @customer.emails.each do |contact|  %>
        <div class="line">
          <%= contact.way %><small><%= contact.type_name %></small>
        </div>
        <% end %>
      </div>      
    </div>
    <div class="block">
      <div class="head">
        <div class="title with_tools">聊天工具</div>
        <div class="tools">
          <%= link_to @customer.ims.many? ? '编辑' : '添加', edit_customer_url(@customer) %>
        </div>
        <div class="clear"></div>
      </div>
      <div class="body">
        <% @customer.ims.each do |contact|  %>
        <div class="line">
          <%= contact.way %><small><%= contact.type_name %></small>
        </div>
        <% end %>
      </div>      
    </div>
    <div class="block">
      <div class="head">
        <div class="title with_tools">网站</div>
        <div class="tools">
          <%= link_to @customer.web_sites.many? ? '编辑' : '添加', edit_customer_url(@customer) %>
        </div>
        <div class="clear"></div>
      </div>
      <div class="body">
        <% @customer.web_sites.each do |contact|  %>
        <div class="line">
          <%= contact.way %><small><%= contact.type_name %></small>
        </div>
        <% end %>
      </div>      
    </div>
    <div class="block">
      <div class="head">
        <div class="title with_tools">地址</div>
        <div class="tools">
          <%= link_to @customer.addresses.many? ? '编辑' : '添加', edit_customer_url(@customer) %>
        </div>
        <div class="clear"></div>
      </div>
      <div class="body">
        <% @customer.addresses.each do |contact|  %>
        <div class="line">
          <%= contact.way %><small><%= contact.type_name %></small>
        </div>
        <% end %>
      </div>      
    </div>
    <div class="block">
      <div class="head">
        <div class="title with_tools">背景资料</div>
        <div class="tools">
          <%= link_to '编辑', edit_customer_url(@customer) %>
        </div>
        <div class="clear"></div>
      </div>
      <div class="body">
        <div class="line">
          <%= @customer.background_info %>
        </div>
      </div>
    </div>
    <!-- <div class="block">
      <div class="head">
        <div class="title with_tools">重要的日期</div>
        <div class="tools">
          <%= link_to '编辑', edit_customer_url(@customer) %>
        </div>
        <div class="clear"></div>
      </div>
      <div class="body">
        <% 4.times do  %>
        <div class="line">
          1989年12月11日<small>生日</small>
        </div>
        <% end %>
      </div>
    </div> -->
  </div>
</div>